package com.whosly.mysql.protocol.packet.impl;

/**
 * 一些常用的不会更改的语句
 *
 * @author fengyang(yueny09 @ 163.com)
 * @date 2023年06月25日 下午2:51
 */
public class CommandPacketEnum {

    public static final NettyCommandPacket _READ_UNCOMMITTED = new NettyCommandPacket();
    public static final NettyCommandPacket _READ_COMMITTED = new NettyCommandPacket();
    public static final NettyCommandPacket _REPEATED_READ = new NettyCommandPacket();
    public static final NettyCommandPacket _SERIALIZABLE = new NettyCommandPacket();
    public static final NettyCommandPacket _AUTOCOMMIT_ON = new NettyCommandPacket();
    public static final NettyCommandPacket _AUTOCOMMIT_OFF = new NettyCommandPacket();
    public static final NettyCommandPacket _COMMIT = new NettyCommandPacket();
    public static final NettyCommandPacket _ROLLBACK = new NettyCommandPacket();

    static {
        _READ_UNCOMMITTED.setPackId((byte)0);
        _READ_UNCOMMITTED.setCmd(CommandPacket.COMMAND_QUERY);
        _READ_UNCOMMITTED.setArg("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED"
                .getBytes());

        _READ_COMMITTED.setPackId((byte)0);
        _READ_COMMITTED.setCmd(CommandPacket.COMMAND_QUERY);
        _READ_COMMITTED.setArg("SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED".getBytes());

        _REPEATED_READ.setPackId((byte)0);
        _REPEATED_READ.setCmd(CommandPacket.COMMAND_QUERY);
        _REPEATED_READ.setArg("SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ".getBytes());

        _SERIALIZABLE.setPackId((byte)0);
        _SERIALIZABLE.setCmd(CommandPacket.COMMAND_QUERY);
        _SERIALIZABLE.setArg("SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE".getBytes());

        _AUTOCOMMIT_ON.setPackId((byte)0);
        _AUTOCOMMIT_ON.setCmd(CommandPacket.COMMAND_QUERY);
        _AUTOCOMMIT_ON.setArg("SET autocommit=1".getBytes());

        _AUTOCOMMIT_OFF.setPackId((byte)0);
        _AUTOCOMMIT_OFF.setCmd(CommandPacket.COMMAND_QUERY);
        _AUTOCOMMIT_OFF.setArg("SET autocommit=0".getBytes());

        _COMMIT.setPackId((byte)0);
        _COMMIT.setCmd(CommandPacket.COMMAND_QUERY);
        _COMMIT.setArg("commit".getBytes());

        _ROLLBACK.setPackId((byte)0);
        _ROLLBACK.setCmd(CommandPacket.COMMAND_QUERY);
        _ROLLBACK.setArg("rollback".getBytes());
    }
}
